package cn.fang2chen.distributed.lock.spring;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 配置参数
 *
 * @author dcmini chen
 * @since 1.0.0
 */
@Data
@ConfigurationProperties(prefix = "distributed.lock")
public class DistributedLockProperties {

    /**
     * 默认循环间隔
     */
    private Long pollingIntervalNano = -1L;

    /**
     * 互斥锁配置
     */
    private MutexConfig mutexConfig = new MutexConfig();

    /**
     * 可重入锁配置
     */
    private ReentrantLockConfig reentrantLockConfig = new ReentrantLockConfig();

    /**
     * token 租赁
     */
    private TokenLeasingConfig tokenLeasingConfig = new TokenLeasingConfig();

    /**
     * 互斥锁配置
     */
    @Data
    public static class MutexConfig {

        /**
         * 是否启用
         */
        private Boolean enabled = true;

        /**
         * 锁本地缓存的时长
         */
        private Long lockCacheExpired = -1l;

    }

    /**
     * 可重入锁配置
     */
    @Data
    public static class ReentrantLockConfig {

        /**
         * 是否启用
         */
        private Boolean enabled = true;

        /**
         * 锁本地缓存的时长
         */
        private Long lockCacheExpired = -1l;

    }

    /**
     * token 租赁
     */
    @Data
    public static class TokenLeasingConfig {

        /**
         * 是否启用
         */
        private Boolean enabled = true;

        /**
         * 锁本地缓存的时长
         */
        private Long lockCacheExpired = -1l;

    }


}

